package com.example.util;

import lombok.Data;

/**
 * ClassName:Result
 * Package:com.example.util
 * User:HP
 * Date:2025/8/17
 * Time:下午8:47
 * Author 周东汉
 * Version 1.0
 * Description:统一响应结果类
 */
@Data
public class Result {

    int code;

    String msg;

    Object data;

    public static Result success() {
        Result result = new Result();
        result.setCode(200);
        result.setMsg("success");
        result.setData(null);
        return result;
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(200);
        result.setMsg("success");
        result.setData(data);
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(500);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }

    public static Result error(int code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }

}
